package App;

import org.apache.log4j.Logger;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import simple.form.controller.Router;
import simple.form.controller.SysInit;

import javax.servlet.DispatcherType;
import java.util.EnumSet;

/**
 * Created by Administrator on 2017/2/22.
 */
public class Home {
    public static Logger log4j = Logger.getLogger(Home.class);
    public static void main(String[] args) {
        int port = 10001;
        try {
            Server server = new Server(port);
            ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
            context.setContextPath("/");
            server.setHandler(context);
            context.addEventListener(new SysInit());
            context.addFilter(Router.class, "*", EnumSet.of(DispatcherType.REQUEST));
//            context.addServlet(QrcodeService.class,"/create_qrcode");
            log4j.info(String.format("Starting web server on port:%d", port));
            server.start();
            log4j.info("Starting Complete. ");
            server.join();
        } catch (Exception e) {
            log4j.error("start http server error",e);
        }
    }
}
